from django.db import models


# Create your models here.


class Projects(models.Model):
    name = models.CharField(max_length=50, verbose_name="项目名称", unique=True)
    describe = models.TextField(default="", null=True, blank=True, verbose_name="项目简介")
    status = models.BooleanField(default=1, verbose_name="项目状态")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间")
    creator = models.CharField(max_length=20, verbose_name='创建者')

    class Meta:
        verbose_name = '项目管理'
        verbose_name_plural = '项目管理'

    def __str__(self):
        return self.name


class Modules(models.Model):
    name = models.CharField(max_length=50, verbose_name="模块名称")
    describe = models.TextField(default="", null=True, blank=True, verbose_name="模块描述")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="添加时间")
    creator = models.CharField(max_length=20, verbose_name='创建者')
    project = models.ForeignKey(Projects, on_delete=models.CASCADE, verbose_name='所属项目')

    class Meta:
        verbose_name = '模块管理'
        verbose_name_plural = '模块管理'

    def __str__(self):
        return self.name
